package define

import (
	"gluenet/internal/agent/driver/helmdriver/search"

	"helm.sh/helm/v3/pkg/release"
)

type CommonDeleteReq struct {
	Guid string `json:"guid" yaml:"guid"`
}

type CommonResp struct {
	IsSuccess bool        `json:"is_success" yaml:"is_success"`
	Message   string      `json:"message" yaml:"message"`
	Data      interface{} `json:"data,omitempty"`
}

type GetAgentInfoResp struct {
	CommonResp
	AgentInfo
}

type CreateContainerReq struct {
	Guid          string            `json:"guid" yaml:"guid"`
	ContainerName string            `json:"containerName" yaml:"containerName"`
	ImageTag      string            `json:"imageTag" yaml:"imageTag"`
	Runtime       string            `json:"runtime" yaml:"runtime"`
	Workdir       string            `json:"workdir" yaml:"workdir"`
	Cmds          []string          `json:"cmds" yaml:"cmds"`
	Envs          map[string]string `json:"envs" yaml:"envs"`
	Ports         map[string]string `json:"ports" yaml:"ports"`
	Mounts        map[string]string `json:"mounts" yaml:"mounts"`

	CpuSet   string  `json:"cpuSet" yaml:"cpuSet"`
	CpuShare int64   `json:"cpuShare" yaml:"cpuShare"`
	Memory   int64   `json:"memory" yaml:"memory"`
	Cpu      float64 `json:"cpu" yaml:"cpu"`

	ServicPerfix string `json:"servicePerfix" yaml:"servicePerfix"`
	ReportEnable bool   `json:"reportEnabel" yaml:"reportEnabel"`
}

type CreateHelmReq struct {
	Guid        string `json:"guid" yaml:"guid"`
	WithJaeger  bool   `json:"jaeger" yaml:"jaeger"`
	WithLinkerd bool   `json:"linkerd" yaml:"linkerd"`
	ReleaseName string `json:"release_name" yaml:"release_name"`
	ChartName   string `json:"chart_name" yaml:"chart_name"`
}

type GetHelmChartReq struct {
	ChartName string `json:"chart_name" yaml:"chart_name"`
}

type GetHelmChartResp struct {
	IsSuccess bool             `json:"is_success" yaml:"is_success"`
	Message   string           `json:"message" yaml:"message"`
	Data      []*search.Result `json:"data" yaml:"data"`
}

type GetHelmReleaseReq struct {
	Guid        string `json:"namespace" yaml:"namespace"`
	ReleaseName string `json:"release_name" yaml:"release_name"`
}

type GetHelmReleaseResp struct {
	IsSuccess bool             `json:"is_success" yaml:"is_success"`
	Message   string           `json:"message" yaml:"message"`
	Data      *release.Release `json:"data" yaml:"data"`
}

type ListHelmReleasesReq struct {
	Guid string `json:"namespace" yaml:"namespace"`
}

type ListHelmReleasesResp struct {
	IsSuccess bool               `json:"is_success" yaml:"is_success"`
	Message   string             `json:"message" yaml:"message"`
	Data      []*release.Release `json:"data" yaml:"data"`
}

type PushReq struct {
	Guid  string `json:"guid" yaml:"guid"`
	Topic string `json:"topic" yaml:"topic"`
}

type UpdateContainerCpuSetReq struct {
	Guid   string `json:"guid" yaml:"guid"`
	CpuSet string `json:"cpuSet" yaml:"cpuSet"`
}

type UpdateContainerCpuRatiosReq struct {
	Guids  []string `json:"guids" yaml:"guids"`
	Ratios []int    `json:"ratios" yaml:"ratios"`
}

type HttpGetProxyReq struct {
	HttpUrl string            `json:"httpUrl" yaml:"httpUrl"`
	Params  map[string]string `json:"params" yaml:"params"`
}

type HttpPostProxyReq struct {
	HttpUrl string                 `json:"httpUrl" yaml:"httpUrl"`
	Body    map[string]interface{} `json:"body" yaml:"body"`
}

type HttpProxyRequestReq struct {
	HttpUrl string                 `json:"httpUrl" yaml:"httpUrl"`
	Method  string                 `json:"method" yaml:"method"`
	Headers map[string]string      `json:"headers" yaml:"headers"`
	Params  map[string]string      `json:"params" yaml:"params"`
	Body    map[string]interface{} `json:"body" yaml:"body"`
}

type HttpProxyResp struct {
	IsSuccess bool   `json:"is_success" yaml:"is_success"`
	Message   string `json:"message" yaml:"message"`
	Data      []byte `json:"data" yaml:"data"`
}

type MaasReq struct {
	MaasURL   string            `json:"maasUrl" yaml:"maasUrl"`
	APIKey    string            `json:"apiKey" yaml:"apiKey"`
	Version   string            `json:"version" yaml:"version"`
	Function  string            `json:"function" yaml:"function"`
	GetParams string            `json:"getParams" yaml:"getParams"`
	Value     map[string]string `json:"value" yaml:"value"`
}

type MaasResp struct {
	IsSuccess bool   `json:"is_success" yaml:"is_success"`
	Message   string `json:"message" yaml:"message"`
	Data      []byte `json:"data" yaml:"data"`
}

type CprofileFlame struct {
	Guid      string `json:"guid" yaml:"guid"`
	Pod       string `json:"pod" yaml:"pod"`
	Container string `json:"container" yaml:"container"`
}

type CprofileFile struct {
	Pod       string `json:"pod" yaml:"pod"`
	Container string `json:"container" yaml:"container"`
	URL       string `json:"url" yaml:"url"`
}

type JaegerService struct {
	URL  string `json:"url" yaml:"url"`
	Guid string `json:"guid" yaml:"guid"`
}

type JaegerOperate struct {
	URL     string `json:"url" yaml:"url"`
	Guid    string `json:"guid" yaml:"guid"`
	Service string `json:"service" yaml:"service"`
}

type JaegerTraces struct {
	URL         string `json:"url" yaml:"url"`
	Guid        string `json:"guid" yaml:"guid"`
	Service     string `json:"service" yaml:"service"`
	Operation   string `json:"operation" yaml:"operation"`
	Limit       string `json:"limit" yaml:"limit"`
	Start       string `json:"start" yaml:"start"`
	End         string `json:"end" yaml:"end"`
	LookBack    string `json:"lookBack" yaml:"lookBack"`
	MaxDuration string `json:"maxDuration" yaml:"maxDuration"`
	MinDuration string `json:"minDuration" yaml:"minDuration"`
	Tags        string `json:"tags" yaml:"tags"`
}

type DagServiceMap struct {
	Range string `json:"range" yaml:"range"`
	End   string `json:"end" yaml:"end"`
	Guid  string `json:"guid" yaml:"guid"`
}

type Service struct {
	Name  string          `json:"name"`
	IP    string          `json:"ip"`
	Ports map[string]Port `json:"ports"`
}

type Request struct {
	SourcePod       string `json:"source_pod"`
	DestinationPod  string `json:"destination_pod"`
	DestinationPort string `json:"destination_port"`
	Method          string `json:"method"`
	Url             string `json:"url"`
	Verdict         string `json:"verdict"`
	Protocol        string `json:"protocol"`
}

type Port struct {
	Port     string   `json:"port"`
	Protocol string   `json:"protocol"`
	UrlS     []string `json:"url"`
}

type DagServiceMapResp struct {
	Graph struct {
		Node map[string]map[string][]int `json:"node"`
	} `json:"graph"`
	Services map[string]Service `json:"services"`
	Requests []Request          `json:"requests"`
}

type DagResponseResp struct {
	TotalCount  float64            `json:"total_count"`
	Latency     map[string]float64 `json:"latency"`
	ErrCount    int                `json:"err_count"`
	SuccessRate float64            `json:"success_rate"`
}

type DagResponse struct {
	Range          string `json:"range" yaml:"range"`
	End            string `json:"end" yaml:"end"`
	SourcePod      string `json:"sourcePod" yaml:"sourcePod"`
	DestinationPod string `json:"destinationPod" yaml:"destinationPod"`
	Port           string `json:"port" yaml:"port"`
	Verdict        string `json:"verdict" yaml:"verdict"`
	Url            string `json:"url" yaml:"url"`
	Method         string `json:"method" yaml:"method"`
	Protocol       string `json:"protocol" yaml:"protocol"`
	Guid           string `json:"guid" yaml:"guid"`
}

type PromQuery struct {
	Query string `json:"query" yaml:"query"`
	Time  string `json:"time" yaml:"time"`
}

type PromQueryRange struct {
	Query string `json:"query" yaml:"query"`
	Start string `json:"start" yaml:"start"`
	End   string `json:"end" yaml:"end"`
	Step  string `json:"step" yaml:"step"`
}

type LogCounts struct {
	Start     string `json:"start" yaml:"start"`
	Guid      string `json:"guid" yaml:"guid"`
	Container string `json:"container" yaml:"container"`
	End       string `json:"end" yaml:"end"`
	Bucket    string `json:"bucket" yaml:"bucket"`
}

type LogInfo struct {
	Start     string `json:"start" yaml:"start"`
	Guid      string `json:"guid" yaml:"guid"`
	Container string `json:"container" yaml:"container"`
	End       string `json:"end" yaml:"end"`
}

// type HttpGetProxyReq struct {
// 	HttpUrl string            `json:"httpUrl" yaml:"httpUrl"`
// 	Params  map[string]string `json:"params" yaml:"params"`
// }

// type HttpPostProxyReq struct {
// 	HttpUrl string                 `json:"httpUrl" yaml:"httpUrl"`
// 	Body    map[string]interface{} `json:"body" yaml:"body"`
// }

// type HttpProxyRequestReq struct {
// 	HttpUrl string                 `json:"httpUrl" yaml:"httpUrl"`
// 	Method  string                 `json:"method" yaml:"method"`
// 	Headers map[string]string      `json:"headers" yaml:"headers"`
// 	Params  map[string]string      `json:"params" yaml:"params"`
// 	Body    map[string]interface{} `json:"body" yaml:"body"`
// }

// type HttpProxyResp struct {
// 	IsSuccess bool   `json:"is_success" yaml:"is_success"`
// 	Message   string `json:"message" yaml:"message"`
// 	Data      []byte `json:"data" yaml:"data"`
// }
